package com.lsh.controller;

import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author ：LiuShihao
 * @date ：Created in 2020/11/6 9:47 上午
 * @desc ：
 */
@RestController
@RequestMapping("/dept")
public class DeptController {

   @GetMapping("/called")
   public Object beCall() {
        System.out.println("dept GET  无参 : 被访问了");
        return "{\"code\":\"8002\"}";
    }
   @GetMapping("/called/{id}")
    public Object beCallById(@PathVariable("id") String id) {
        System.out.println("dept  GET 带参 表单形式    : 被访问了");
        return "{\"code\":\"8002\",\"id\":\""+id+"\"}";
    }

    @GetMapping("/called2")
    public Object beCallById2(@RequestParam("id") String id) {
        System.out.println("dept  GET 带参 路径形式: 被访问了");
        return "{\"code\":\"8002\",\"id\":\""+id+"\"}";
    }
    @PostMapping("/beCalledPost")
    public Object beCalledPost(@RequestBody Map<String,String> map){
        System.out.println("dept  POST 带参 : 被访问了");
        return "{\"code\":\"8002\",\"id\":\""+map.get("id")+"\",\"name\":\""+map.get("name")+"\"}";
    }
}
